package com.ecoolex.chinadutyfree.retailer.api.graphql;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.lang.NonNull;

import com.ecoolex.chinadutyfree.retailer.entity.GoodsCategory;
import com.ecoolex.chinadutyfree.retailer.entity.GoodsCategoryMarketing;
import com.ecoolex.chinadutyfree.retailer.ws.GoodsService;
import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.web.api.graphql2.annotation.GraphQL2Module;
import com.ecoolex.framework.web.api.graphql2.annotation.QueryField;
import com.ecoolex.framework.web.api.graphql2.annotation.Source;
import com.ecoolex.framework.web.api.graphql2.annotation.TypeField;
import com.ecoolex.framework.web.api.graphql2.annotation.GraphQL2Module.Type;

@GraphQL2Module(type = Type.User, description = "商品分类推荐查询")
public class GoodsCategoryMarketingGraphql {

	@Reference
	private GoodsService goodsService;
	
	@TypeField(type = GoodsCategoryMarketing.class,field = "goodsCategory" ,description = "商品分类")
	public GoodsCategory goodsCategory(@Source GoodsCategoryMarketing source) {
		return goodsService.getCategoryById(source.getCategoryId());
	}
	
	@QueryField(field = "goodsCategoryMarketingList", description = "商品分类推荐列表")
	public Pagination<GoodsCategoryMarketing> query(@NonNull Page page){
		return goodsService.goodsCategoryMarketingListForH5(page);
	}
	
	@QueryField(field = "goodsCategoryMarketing", description = "商品分类推荐详情")
	public GoodsCategoryMarketing get(@NonNull Integer id){
		return goodsService.getGoodsCategoryMarketingForH5(id);
	}
}
